frame clock: adjust reported frame time
authorYariv Barkan <21448-yarivb@users.noreply.gitlab.gnome.org>
Wed, 10 Jun 2020 07:45:14 +0000 (10:45 +0300)
committerAlexander Larsson <alexl@redhat.com>
Mon, 15 Jun 2020 06:54:17 +0000 (08:54 +0200)
commit9c5d6eaa718ab37f91fb847a3e33dd8a91e3c1c9
treea65a5cd164fe0871d4cf85ba64ef58aefda4f3e2
parentc49318e973bab3091bf146af058a0f1b42b6effd
frame clock: adjust reported frame time

When an animation is started while the application is idle, that often
happens as a result of some external event. This can be an input event,
an expired timer, data arriving over the network etc. The result is that
the first animation clock cycle could be scheduled at some random time,
as opposed to follow up cycles which are usually scheduled right after a
vsync.

Since the frame time we report to the application is correlated to the
time when the frame clock was scheduled to run, this can result in
uneven times reported in the first few animation frames. In order to fix
that, we measure the phase of the first clock cycle - i.e. the offset
between the first cycle and the preceding vsync. Once we start receiving
"frame drawn" signals, the cadence of the frame clock scheduling becomes
tied to the vsync. In order to maintain the regularity of the reported
frame times, we adjust subsequent reported frame times with the
aforementioned phase.
gdk/gdkframeclockidle.c